package com.amor.ui

import android.os.SystemClock
import android.view.ViewGroup
import android.webkit.WebSettings
import com.amor.widget.ExWebView
import com.hy.frame.util.LogUtil
import kotlin.system.exitProcess


class ProcessWebActivity : BaseWebActivity() {

    private val mWeb by lazy {
        ExWebView(this)
    }

    override fun initView() {
        super.initView()
        initStartTime = SystemClock.elapsedRealtime()
        LogUtil.d(TAG, "初始化WebView start")
        initWebSettings(mWeb.settings, WebSettings.LOAD_CACHE_ELSE_NETWORK)
        initClient(mWeb)
        mBinding?.container?.addView(mWeb, ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
        LogUtil.d(TAG, "初始化WebView end time=%sms".format(SystemClock.elapsedRealtime() - initStartTime))
        showConsole("初始化WebView耗时=%sms\n".format(SystemClock.elapsedRealtime() - initStartTime))
    }

    override fun initData() {
        super.initData()
        mWeb.loadUrl(URL)
    }

    override fun onDestroy() {
        super.onDestroy()
        exitProcess(0)
    }

    companion object {

        private const val TAG = "CacheWebActivity"
        const val URL = "https://m.huize.com/zhishi/tuijian/0"

    }
}